//
//  TableViewCellstyle1.m
//  BAOASystem
//
//  Created by michael on 2018/1/17.
//  Copyright © 2018年 czd. All rights reserved.
//

#import "TableViewCellstyle1.h"
#import "XLCycleCollectionView.h"

@implementation TableViewCellstyle1
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        //不要把控件add到view上
        //add到contentView才是你最正确的选择
 
    }
    return self;
}
- (void)awakeFromNib {
    [super awakeFromNib];
          self.selectionStyle = UITableViewCellSelectionStyleNone;

     _cyleView = [[XLCycleCollectionView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, (KScreenWidth-30)/4)];

 
    // Initialization code
  
[_cyleView.collectionView reloadData];
}
-(void)setDict:(NSDictionary *)dict{
    _dict = dict;
   
}
- (void)layoutSubviews{
[super layoutSubviews];

_titlelabel.text = _dict[@"ctgName"];
_zhutuilabel.text = NSLocalizedString(@"主推分类", nil);
_fabulabel.text = NSLocalizedString(@"最新发布", nil);
_reshoulabel.text = NSLocalizedString(@"热搜词",nil);
_tuijianlabel.text = NSLocalizedString(@"主推商品", nil);
NSArray *ctgMainPushProductarray = _dict[@"ctgMainPushflList"];
if (ctgMainPushProductarray.count!=0) {
  NSDictionary *dic =ctgMainPushProductarray[0];
  if (ctgMainPushProductarray.count>1) {

[_zhutuibutton1 setTitle:ctgMainPushProductarray[1][@"title"] forState:UIControlStateNormal];
}  if (ctgMainPushProductarray.count>2) {

[_zhutuibutton2 setTitle:ctgMainPushProductarray[2][@"title"] forState:UIControlStateNormal];
}  if (ctgMainPushProductarray.count>3) {

[_zhutuibutton3 setTitle:ctgMainPushProductarray[3][@"title"] forState:UIControlStateNormal];
}
[_zhutuibom sd_setImageWithURL:[NSURL URLWithString:dic[@"fileurl"]] forState:UIControlStateNormal];

}

NSArray *ctgNewProductListarray = _dict[@"ctgNewProductList"];
if (ctgNewProductListarray.count!=0) {

NSDictionary *ctgNewProductListdic =ctgNewProductListarray[0];
[_faburightbutton sd_setImageWithURL:[NSURL URLWithString:ctgNewProductListdic[@"fileurl"]] forState:UIControlStateNormal];
  if (ctgNewProductListarray.count>1) {

[_fabubutton1 setTitle:ctgNewProductListarray[1][@"title"] forState:UIControlStateNormal];
}  if (ctgNewProductListarray.count>2) {

[_fabubutton2 setTitle:ctgNewProductListarray[2][@"title"] forState:UIControlStateNormal];
}  if (ctgNewProductListarray.count>3) {

[_fabuaction3 setTitle:ctgNewProductListarray[3][@"title"] forState:UIControlStateNormal];
}
}
NSArray *ctgHotKeyWordListarray = _dict[@"ctgHotKeyWordList"];
if (ctgHotKeyWordListarray.count!=0) {
  if (ctgHotKeyWordListarray.count>0) {

[_reshoubutton1 setTitle:ctgHotKeyWordListarray[0][@"title"] forState:UIControlStateNormal];
}  if (ctgHotKeyWordListarray.count>1) {

[_reshoubutton2 setTitle:ctgHotKeyWordListarray[1][@"title"] forState:UIControlStateNormal];
}  if (ctgHotKeyWordListarray.count>2) {

[_reshoubutton3 setTitle:ctgHotKeyWordListarray[2][@"title"] forState:UIControlStateNormal];
}

}

//传值
   _cyleView.data = _dict[@"ctgMainPushProduct"];
 [self.bomview addSubview:_cyleView];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (IBAction)zhutuiaction1:(id)sender {
NSArray *ctgMainPushProductarray = _dict[@"ctgMainPushflList"];
if (ctgMainPushProductarray.count>1){
NSDictionary *dic =ctgMainPushProductarray[1];

shangpinxqViewController *vc = [[shangpinxqViewController alloc]init];
vc.pdid = dic[@"id"];
vc.hidesBottomBarWhenPushed = YES;
[self.ViewController.navigationController pushViewController:vc animated:YES];
}
}

- (IBAction)zhutuiaction2:(id)sender {
NSArray *ctgMainPushProductarray = _dict[@"ctgMainPushflList"];
if (ctgMainPushProductarray.count>2){
NSDictionary *dic =ctgMainPushProductarray[2];

shangpinxqViewController *vc = [[shangpinxqViewController alloc]init];
vc.pdid = dic[@"id"];
vc.hidesBottomBarWhenPushed = YES;
[self.ViewController.navigationController pushViewController:vc animated:YES];
}
}

- (IBAction)zhutuiaction3:(id)sender {
NSArray *ctgMainPushProductarray = _dict[@"ctgMainPushflList"];
if (ctgMainPushProductarray.count>3){
NSDictionary *dic =ctgMainPushProductarray[3];

shangpinxqViewController *vc = [[shangpinxqViewController alloc]init];
vc.pdid = dic[@"id"];
vc.hidesBottomBarWhenPushed = YES;
[self.ViewController.navigationController pushViewController:vc animated:YES];
}
}
- (IBAction)zhutuibomaction:(id)sender {
NSArray *ctgMainPushProductarray = _dict[@"ctgMainPushflList"];
if (ctgMainPushProductarray.count>0){
NSDictionary *dic =ctgMainPushProductarray[0];

shangpinxqViewController *vc = [[shangpinxqViewController alloc]init];
vc.pdid = dic[@"id"];
vc.hidesBottomBarWhenPushed = YES;
[self.ViewController.navigationController pushViewController:vc animated:YES];
}
}
- (IBAction)fabuaction1:(id)sender {
NSArray *ctgNewProductListarray = _dict[@"ctgNewProductList"];
if (ctgNewProductListarray.count>1){
NSDictionary *dic =ctgNewProductListarray[1];

shangpinxqViewController *vc = [[shangpinxqViewController alloc]init];
vc.pdid = dic[@"id"];
vc.hidesBottomBarWhenPushed = YES;
[self.ViewController.navigationController pushViewController:vc animated:YES];
}
}
- (IBAction)fabuaction2:(id)sender {
NSArray *ctgNewProductListarray = _dict[@"ctgNewProductList"];
if (ctgNewProductListarray.count>2){
NSDictionary *dic =ctgNewProductListarray[2];

shangpinxqViewController *vc = [[shangpinxqViewController alloc]init];
vc.pdid = dic[@"id"];
vc.hidesBottomBarWhenPushed = YES;
[self.ViewController.navigationController pushViewController:vc animated:YES];
}
}

- (IBAction)fabuaction3:(id)sender {
NSArray *ctgNewProductListarray = _dict[@"ctgNewProductList"];
if (ctgNewProductListarray.count>3){
NSDictionary *dic =ctgNewProductListarray[3];

shangpinxqViewController *vc = [[shangpinxqViewController alloc]init];
vc.pdid = dic[@"id"];
vc.hidesBottomBarWhenPushed = YES;
[self.ViewController.navigationController pushViewController:vc animated:YES];
}
}

- (IBAction)faburightaction:(id)sender {
NSArray *ctgNewProductListarray = _dict[@"ctgNewProductList"];
if (ctgNewProductListarray.count>0){
NSDictionary *dic =ctgNewProductListarray[0];

shangpinxqViewController *vc = [[shangpinxqViewController alloc]init];
vc.pdid = dic[@"id"];
vc.hidesBottomBarWhenPushed = YES;
[self.ViewController.navigationController pushViewController:vc animated:YES];
}
}


- (IBAction)reshouaction2:(id)sender {
NSArray *ctgHotKeyWordListarray = _dict[@"ctgHotKeyWordList"];
if (ctgHotKeyWordListarray.count>1){
NSDictionary *dic =ctgHotKeyWordListarray[1];

shangpinxqViewController *vc = [[shangpinxqViewController alloc]init];
vc.pdid = dic[@"id"];
vc.hidesBottomBarWhenPushed = YES;
[self.ViewController.navigationController pushViewController:vc animated:YES];
}
}

- (IBAction)reshouaction3:(id)sender {
NSArray *ctgHotKeyWordListarray = _dict[@"ctgHotKeyWordList"];
if (ctgHotKeyWordListarray.count>2){
NSDictionary *dic =ctgHotKeyWordListarray[2];

shangpinxqViewController *vc = [[shangpinxqViewController alloc]init];
vc.pdid = dic[@"id"];
vc.hidesBottomBarWhenPushed = YES;
[self.ViewController.navigationController pushViewController:vc animated:YES];
}
}
- (IBAction)reshouaction1:(id)sender {
NSArray *ctgHotKeyWordListarray = _dict[@"ctgHotKeyWordList"];
if (ctgHotKeyWordListarray.count>0){
NSDictionary *dic =ctgHotKeyWordListarray[0];

shangpinxqViewController *vc = [[shangpinxqViewController alloc]init];
vc.pdid = dic[@"id"];
vc.hidesBottomBarWhenPushed = YES;
[self.ViewController.navigationController pushViewController:vc animated:YES];
}
}
@end
